import Vue from 'vue'
import Vuex from 'vuex'
import { getTem } from '../api/templates'
import { getExa } from '../api/examples'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    dataList:[],
    templates:[],
    examples:[]
  },
  mutations: {
    CHANGE_DATA(state,data){
      state.dataList = [...data]
    },
    CHANGE_Tem(state,data){
      state.templates = [...data]
    },
    CHANGE_Exa(state,data){
      state.examples = [...data]
    }
  },
  actions: {
    async getTemplates({ commit }){
      let templates = await getTem()
      commit('CHANGE_Tem', templates.data)
    },
    async getExample({ commit }){
      let example = await getExa()
      commit('CHANGE_Exa', example.data)
    }
  },
  modules: {
    
  }
})
